'use strict';
const {
    Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
    class Article extends Model {
        /**
         * Helper method for defining associations.
         * This method is not a part of Sequelize lifecycle.
         * The `models/index` file will call this method automatically.
         */
        static associate(models) {
            // define association here
        }
    }
    Article.init({
        title: {
            type: DataTypes.STRING,
            allowNull: false,
            validate:{
                //没有传标题时，报错提示标题必须存在
                notNull:{
                    msg:"标题必须存在"
                },
                //没有传标题的值时，报错提示标题不能为空
                notEmpty:{
                    msg:"标题不能为空"
                },
                len:{
                    args:[2,45],
                    msg:'长度必须在2~45个字符之间'
                }
            }
        },
        content: DataTypes.TEXT
    }, {
        sequelize,
        modelName: 'Article',
    });
    return Article;
};